%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graph-theory-algorithms-book/
%%
%% Copyright (C) 2009--2011 Minh Van Nguyen <nguyenminh2@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}

\usepackage{subfigure}
\usepackage{tikz}
\usepackage{tkz-berge}  %% for drawing combinatorial graphs
\usetikzlibrary{external}
\tikzexternalize{Boruvkas-algorithm}

\begin{document}

\begin{figure}
\subfigure[Original undirected graph.]{
\label{fig:Boruvkas_algorithm:original_undirected_graph}
\begin{tikzpicture}
[lineDecorate/.style={-,thick},%
  nodeDecorate/.style={shape=circle,inner sep=1.5pt,draw,thick},%
  scale=0.8]
\scriptsize
%% nodes or vertices
\foreach \nodename/\x/\y in {
  0/0/0, 1/4/0, 2/4/4, 3/0/4, 4/-2/2, 5/6/2, 6/2/6}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {\scriptsize$\nodename$};
}
%% edges or lines
\tikzstyle{EdgeStyle}=[-,thick]
\tikzstyle{LabelStyle}=[fill=white]
\foreach \startnode/\endnode/\bend/\weight in {
  0/1/bend left=0/1, 0/2/bend left/2, 0/3/bend left=0/5,
  0/4/bend left=0/9, 1/2/bend left=0/3, 1/3/bend left/6,
  1/5/bend left=0/11, 2/3/bend left=0/4, 3/4/bend left=0/9.5,
  3/6/bend left=0/8, 4/6/bend left/7, 5/6/bend right/10}
{
  \Edge[label=$\weight$,style=\bend](\startnode)(\endnode)
}
\end{tikzpicture}
}
%%
%%
\qquad
\subfigure[0th iteration of while loop.]{
\begin{tikzpicture}
[lineDecorate/.style={-,thick},%
  nodeDecorate/.style={shape=circle,inner sep=1.5pt,draw,thick},%
  scale=0.8]
%% nodes or vertices
\foreach \nodename/\x/\y in {
  0/0/0, 1/4/0, 2/4/4, 3/0/4, 4/-2/2, 5/6/2, 6/2/6}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {\scriptsize$\nodename$};
}
\end{tikzpicture}
}
%%
%%
\subfigure[1st iteration of while loop.]{
\begin{tikzpicture}
[lineDecorate/.style={-,thick},%
  nodeDecorate/.style={shape=circle,inner sep=1.5pt,draw,thick},%
  scale=0.8]
\scriptsize
%% nodes or vertices
\foreach \nodename/\x/\y in {
  0/0/0, 1/4/0, 2/4/4, 3/0/4, 4/-2/2, 5/6/2, 6/2/6}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {\scriptsize$\nodename$};
}
%% edges or lines
\tikzstyle{EdgeStyle}=[-,thick]
\tikzstyle{LabelStyle}=[fill=white]
\foreach \startnode/\endnode/\bend/\weight in {
  0/1/bend left=0/1, 0/2/bend left/2, 2/3/bend left=0/4,
  4/6/bend left/7, 5/6/bend right/10}
{
  \Edge[label=$\weight$,style=\bend](\startnode)(\endnode)
}
\end{tikzpicture}
}
%%
%%
\qquad
\subfigure[2nd iteration of while loop.]{
\label{fig:Boruvkas_algorithm:final_minimum_spanning_tree}
\begin{tikzpicture}
[lineDecorate/.style={-,thick},%
  nodeDecorate/.style={shape=circle,inner sep=1.5pt,draw,thick},%
  scale=0.8]
\scriptsize
%% nodes or vertices
\foreach \nodename/\x/\y in {
  0/0/0, 1/4/0, 2/4/4, 3/0/4, 4/-2/2, 5/6/2, 6/2/6}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {\scriptsize$\nodename$};
}
%% edges or lines
\tikzstyle{EdgeStyle}=[-,thick]
\tikzstyle{LabelStyle}=[fill=white]
\foreach \startnode/\endnode/\bend/\weight in {
  0/1/bend left=0/1, 0/2/bend left/2, 2/3/bend left=0/4,
  3/6/bend left=0/8, 4/6/bend left/7, 5/6/bend right/10}
{
  \Edge[label=$\weight$,style=\bend](\startnode)(\endnode)
}
\end{tikzpicture}
}
\end{figure}

\end{document}
